package com.yaorange.module.system.service.impl;

import com.yaorange.module.system.repository.SysRolePermissionRepository;
import com.yaorange.module.system.service.SysRolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  角色权限服务实现类
 */
@Service
public class SysRolePermissionServiceImpl implements SysRolePermissionService {
    @Autowired
    private SysRolePermissionRepository sysRolePermissionRepository;

    @Override
    public void deleteByRoleId(Long roleId) {
        sysRolePermissionRepository.deleteRelationByRoleId(roleId);
    }

    @Override
    public void deleteByRoleIds(List<Long> ids) {
        sysRolePermissionRepository.deleteRelationByRoleIds(ids);
    }

    @Override
    public void insertBatch(List<Long> permissionIds, Long roleId) {
        if(permissionIds!=null && permissionIds.size()>0){
            sysRolePermissionRepository.insertBatchRelation(permissionIds, roleId);
        }
    }
}
